package com.robusta.app.catalogue.model;

import com.robusta.app.domain.Domain;
import com.robusta.app.domain.YesNo;
import com.robusta.app.model.persistence.AuditListener;
import com.robusta.app.model.persistence.Creatable;
import com.robusta.app.model.persistence.Updatable;
import org.apache.commons.lang3.builder.ToStringBuilder;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "CATALOGUE_ENTRY") @EntityListeners(AuditListener.class)
public class CatalogueEntryModel extends com.robusta.app.model.persistence.Entity implements Serializable, Creatable, Updatable {
    @Id
    @Column(name = "ENTRY_ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @ManyToOne
    @JoinColumn(name="CATALOGUE_ID", nullable=false)
    private CatalogueModel catalogue;

    @Column(name = "DESCRIPTION", nullable = false)
    private String description;

    @Column(name = "DOMAIN", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private Domain domain;

    @Column(name = "LATERALITY", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private YesNo laterallyEnabled;


    @Column(name = "ACTIVE", nullable = false)
    @Enumerated(EnumType.ORDINAL)
    private YesNo active;

    @Override
    public String toString() {
        return ToStringBuilder.reflectionToString(this);
    }

    public Long getId() {
        return id;
    }

    public String getDescription() {
        return description;
    }

    public Domain getDomain() {
        return domain;
    }

    public YesNo getLaterallyEnabled() {
        return laterallyEnabled;
    }

    public YesNo getActive() {
        return active;
    }
}
